package com.hx.dc.controllor;

import com.hx.dc.entity.*;
import com.hx.dc.service.DcCatagotyService;
import com.hx.dc.service.DcEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("catalog")
public class CatalogAction extends BaseAction {

	@Autowired
	private DcEmployeeService dcEmployeeService;

	@Autowired
	private DcCatagotyService dcCatagotyService;

	@RequestMapping(value = "/catamana")
	@ResponseBody
	public Object login(HttpSession session) {
		DcRole dcRole= new DcRole();
		dcRole.setRoleName(0);

		List list=dcCatagotyService.selectListUseRight(dcRole);
		return list;
	}


	@RequestMapping(value = "/select")
	@ResponseBody
	// easyui提交数据：page:1 rows:15
	public Object select(DcCatagory dcCatagory) {
		List list=dcCatagotyService.selectList(dcCatagory);
		Map map=new HashMap();
		map.put("rows",list);
		return map;
	}

	@RequestMapping(value = "/cataadd")
	@ResponseBody
	// easyui提交数据：page:1 rows:15
	public Object addCata(DcCatagory dcCatagory) {
		dcCatagotyService.insert(dcCatagory);
		return null;
	}

	@RequestMapping(value = "/cataupdate")
	@ResponseBody
	// easyui提交数据：page:1 rows:15
	public Object updateCata(DcCatagory dcCatagory) {
		dcCatagotyService.update(dcCatagory);
		return null;
	}
	@RequestMapping(value = "/catadel")
	@ResponseBody
	// easyui提交数据：page:1 rows:15
	public Object delCata(String name,DcCatagory dcCatagory) {
		dcCatagory.setCatagoryName(name);
		dcCatagotyService.delete(dcCatagory);
		return null;
	}
}
